package cn.gdcp.intent;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {
    private Button btn1;
    private Button btn2;
    private Button btn3;
    private Button btn4;
    private Button btn5;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

          initBundler();
          btn1Event();
          btn2Event();
          btn3Event();
          btn4Event();
          btn5Event();


    }

    private void btn5Event() {
        btn5.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent =new Intent();
                intent.setClassName("cn.gdcp.demob","MainActivity");
                startActivity(intent);
            }
        });
    }

    private void btn4Event() {
        btn4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent =new Intent();

                intent.setAction("DEMOB");
                startActivity(intent);
            }
        });

    }

    private void btn3Event() {

        btn3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent =new Intent();
                intent.setAction("MAIN3");
                intent.addCategory("MAIN3");
                startActivity(intent);
            }
        });
    }

    private void btn2Event() {
        btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                   Intent intent =new Intent();
                   intent.setAction("MAIN2");
                   startActivity(intent);
            }
        });

    }

    private void btn1Event() {
        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent =new Intent(MainActivity.this,Main2Activity.class);
                startActivity(intent);
            }
        });

    }

    private void initBundler() {
                btn1=findViewById(R.id.btn_1);
                btn2=findViewById(R.id.btn_2);
                btn3=findViewById(R.id.btn_3);
                btn4=findViewById(R.id.btn_4);
                btn5=findViewById(R.id.btn_5);
    }
}
